Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Time dependent QDM #226

Merged
merged 26 commits into from
Jul 18, 2024
Merged

Time dependent QDM #226

merged 26 commits into from
Jul 18, 2024

Conversation

castelao
Copy link
Member

QDM was previously implemented to operate in a full time series, but PresRat requires seasonal CDFs. This was first achieved with a window sliding version of bias.QuantileDeltaMappingCorrection, but later I generalized the standard QDM to run on any time periods. That satisfies the case of n=1 as it was before, as well as n=12 which is approximately the monthly solution.

The #215 already incorporated these modifications but for the sake of simplicity, this PR should be merged before #215.

A masking for measurements outside the intended time window of interest.
A masking for measurements outside the intended time window of interest.
Building it directly in the standard QDM method.
A requirements to estimate parameters by time window.
This allows monthly quantiles or any other scales.
Expects the CDFs were estimated within time windows and apply the QDM
correction respecting those.
This is used to support applying filters and masks.
A different direction. Instead of that, I generatlized the standard
QuantileDeltaMappingCorrection to deal with N periods, which N=1 is the
same behavior of the original function.
Using named arguments allow more freedom on the functions signatures
thus more freedom for refactoring. Here we initiated the requirement on
time to be able to apply QDM on different time scales, such as
seasonally.
@castelao castelao self-assigned this Jul 15, 2024
@castelao castelao mentioned this pull request Jul 15, 2024
@castelao
Copy link
Member Author

@grantbuster @bnb32 , whenever you have a chance, could you review this PR, please? It will make easier for you to review #215.

This PR covers the time dependent solution for QDM. Instead of monthly it is generalized for any time interval. If we use 24 intervals with 30 day time window it would give us still the monthly scale but one estimate every 15 days, which would minimize the jump between on month transitions. Also, with that we avoid having to interpolate when applying and using instead the nearest value. More intervals we add, higher resolution, with an extreme of 365 intervals would lead to one CDF for each day of the year.

sup3r/bias/qdm.py Outdated Show resolved Hide resolved
sup3r/bias/qdm.py Show resolved Hide resolved
sup3r/bias/qdm.py Outdated Show resolved Hide resolved
sup3r/bias/qdm.py Show resolved Hide resolved
sup3r/bias/bias_transforms.py Show resolved Hide resolved
sup3r/bias/qdm.py Show resolved Hide resolved
sup3r/bias/bias_transforms.py Outdated Show resolved Hide resolved
Copy link
Collaborator

@bnb32 bnb32 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ill let Grant double check the implementation ;) I just have some random comments.

sup3r/bias/bias_transforms.py Outdated Show resolved Hide resolved
sup3r/bias/bias_transforms.py Outdated Show resolved Hide resolved
sup3r/preprocessing/data_handling/base.py Outdated Show resolved Hide resolved
In case of a resolution higher than daily, it would make sense using the
window extent without rounding it. Also fix a sign when after 365.
@castelao
Copy link
Member Author

@grantbuster @bnb32 , I'm sorry I forgot to ping you yesterday. I believe that I covered all the requests. Please let me know if it is ready to merge.

@grantbuster
Copy link
Member

@castelao looks good thanks for implementing this!

@castelao castelao merged commit b2f2ad9 into main Jul 18, 2024
12 checks passed
@castelao castelao deleted the seasonal_qdm branch July 18, 2024 18:18
github-actions bot pushed a commit that referenced this pull request Jul 18, 2024
* Initializing WindowedQuantileDeltaMappingCorrection

* feat: window_mask() method

A masking for measurements outside the intended time window of interest.

* feat: window_mask() method directly on QDM

A masking for measurements outside the intended time window of interest.
Building it directly in the standard QDM method.

* refact: run_single including bias time index

A requirements to estimate parameters by time window.

* feat: Quantiles estimated within moving time windows

This allows monthly quantiles or any other scales.

* refactor: local_qdm running on time windows

Expects the CDFs were estimated within time windows and apply the QDM
correction respecting those.

* feat: Method to guide periods along a year

This is used to support applying filters and masks.

* doc: Info on assuming nearest available CDF

* clean: Removing WindowedQuantileDeltaMappingCorrection

A different direction. Instead of that, I generatlized the standard
QuantileDeltaMappingCorrection to deal with N periods, which N=1 is the
same behavior of the original function.

* refactor: Using named arguments

Using named arguments allow more freedom on the functions signatures
thus more freedom for refactoring. Here we initiated the requirement on
time to be able to apply QDM on different time scales, such as
seasonally.

* Adding ipython to dev environment

* test: Adjusting tests to run with new temporal QDM

* cfg: Updating pixi.lock

* doc: window_mask()

* doc, style: _window_center()

* style:

* style:

* fix: Use nearest window center

* Replacing variable t by idt

As requested by @grantbuster

* refact: Renaming variables

As requested by @grantbuster

* refact, fix: window_mask doesn't need rouding

In case of a resolution higher than daily, it would make sense using the
window extent without rounding it. Also fix a sign when after 365.

* test: Testing window_mask()

* doc: Improving window_mask() documentation

* doc: Updating documentation to reflect new dimension on time window

Issue noticed by @grantbuster

* refact: Renaming time to time_index

As requested by @bnb32.

* doc: Information on the reference attributes

As requested by @grantbuster.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants